varying vec3 pos;
varying vec2 texCoord;
uniform sampler2D cloud;
uniform vec3 center;

float module(vec3 a, vec3 b) {
    vec3 c = a - b;
    return sqrt(c.x*c.x + c.y*c.y + c.z*c.z);
}

void main(void) {
    vec4 color = texture2D(cloud,texCoord);
    float fren = module(center,pos);
    fren += 1.0;
    float fren2 = fren;
    fren2 /= 30.0;
    fren /= 25.0;
    fren2 = 1.0 - min(1.0,fren2);
    fren = 1.0 - min(1.0,fren);
    color.w *= fren;
    color.x = 1.0*fren2 + color.x*(1.0 - fren2);
    color.y = 0.6*fren2 + color.y*(1.0 - fren2);
    color.z = 0.2*fren2 + color.z*(1.0 - fren2);
    gl_FragColor = color;
}
